package com.lxq.market.util;

import com.lxq.market.model.User;

import java.util.HashMap;

public class SessionSignIn {

    private static final SessionSignIn signIn=new SessionSignIn();

    private final HashMap<String, User> userHashMap=new HashMap<>();

    public static SessionSignIn getInstance() {
        return signIn;
    }

    public void addSign(String sessionId,User user){
        userHashMap.put(sessionId,user);
    }

    public void remove(String sessionId){
        userHashMap.remove(sessionId);
    }

    public User find(String sessionId){
        return userHashMap.get(sessionId);
    }

    public boolean signed(String sessionId){
        return userHashMap.get(sessionId) != null;
    }
}
